#ifndef     __BOX_MOTORS_H
#define     __BOX_MOTORS_H

#include "../../utils/nocopyable.h"
#include "../../utils/object.h"
#include "../../utils/error.h"

namespace driver {

class BoxMotors : private utils::NoCopyable {

public:
    enum class Dir : uint8_t {
        UP = 0x00,
        DOWN = 0x01,
        BRAKE = 0x02,
        DUMP = UP,
        RESET = DOWN,
    };

    static constexpr uint32_t UPDOWN_TIMEOUT = 10 * 1000;
    static constexpr uint32_t DUMP_TIMEOUT = 10 * 1000;

    static constexpr uint32_t FOREVER = 60 * 1000;

    BoxMotors();

    utils::Error up(uint32_t duration = FOREVER);
    utils::Error down(uint32_t duration = FOREVER);

    utils::Error dump(uint32_t duration = FOREVER);
    utils::Error dump_reset(uint32_t duration = FOREVER);

    void pde_lock();
    void pde_unlock();

private:
    static void set_dir(Dir dir);
};

inline utils::Object<BoxMotors> boxMotors;

}

#endif
